<?php
$ssFilter = $this->arrParam['ssFilter'];
$action_link = $this->baseUrl($this->currentController . '/filter/type/order');
$lblPicture = $this->cmsLinkSort('Picture', 'p.picture', $ssFilter, $this->imgUrl . '/icon', $action_link);
$lblStatus = $this->cmsLinkSort('Status', 'p.status', $ssFilter, $this->imgUrl . '/icon', $action_link);

$lblName = $this->cmsLinkSort('Product Name', 'p.name', $ssFilter, $this->imgUrl . '/icon', $action_link);
$lblPrice = $this->cmsLinkSort('Price', 'p.price', $ssFilter, $this->imgUrl . '/icon', $action_link);
$lblID = $this->cmsLinkSort('ID', 'p.id', $ssFilter, $this->imgUrl . '/icon', $action_link);

$lblCategory = $this->cmsLinkSort('Category', 'category_name', $ssFilter, $this->imgUrl . '/icon', $action_link);
$lblOrder = $this->cmsLinkSort ( 'Order', 'p.order', $ssFilter, $this->imgUrl . '/icon', $action_link );

// Create Selectbox Category
$linkSlbCategory = $this->baseUrl($this->currentController . '/filter/type/group');
$options = $this->slbCategory;
$slbCategory = $this->formSelect('cat_id', $ssFilter['cat_id'], array('onchange' => "OnSubmitForm('" . $linkSlbCategory . "')"), $options);

$selectCategory = '<b>Category :</b>' . $slbCategory;

// Create Search Area
$keywords = $this->formText('keywords', $ssFilter['keywords'], array('class' => 'txtshort'));
$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');
$btnSearch = $this->formButton('search-now', 'Search Now', array('Onclick' => "OnSubmitForm('" . $linkSearch . "')"));
$linkResetSearch = $linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
$btnResetSearch = $this->formButton('clear-keywords', 'Clear', array('Onclick' => "OnSubmitForm('" . $linkResetSearch . "')"));

?>
<form name="appForm" method="post" action="">
<?php echo $this->render('product/toolbar/index.php') ?>
<div class="clr"></div>
<?php // echo $this->render('product/sublink/index.php') ?>
<!-- BEGIN: CONTENT -->
	<div id="element-box">
    <div class="t">
    	<div class="t">
    		<div class="t"></div>
    	</div>
    </div>
		<div class="m">
			<!-- BEGIN: ELEMENT BOX -->

      <div id="filters">
      	<div style="float: left;">
      		<?php echo $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch; ?>
      	</div>
      	<div style="float: right;">
      		<?php //echo $selectCategory; ?>
      	</div>
      	<div class="clr"></div>
      </div>
			<!-- Area 4: In du lieu lay tu database -->
			<table class="adminlist">
        <thead>
        	<tr>
        		<th width="43"><input type="checkbox" name="checkbox"
        			id="checkbox" onclick="checkedAll()"></th>
        		<th width="100"><?php echo $lblPicture; ?></th>
        		<th><?php echo $lblName; ?></th>
        		<th width="70"><?php echo $lblStatus; ?></th>
        		<th width="100"><?php echo $lblPrice; ?></th>
            <th width="100"><?php echo $lblOrder; ?></th>
        		<th width="150"><?php echo $lblCategory; ?></th>
        		<th width="90">Control</th>
        		<th width="40"><?php echo $lblID; ?></th>
        	</tr>
        </thead>
		
				<?php
          foreach ($this->Items as $key => $value) {
            $id = $value['id'];
            $picture = $value['picture'];
            $name = $value['name'];
            $product_price = $value['price'];
            if ($value['selloff'] != 0) {
              $product_price = $value['selloff'];
            }
            $category_name = $value['category_name'];
            $status = $value['status'];
            if ($status == 1) {
              $linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);
              $status = $this->cmsIconButton('Active', $this->imgUrl . '/icon/active.png', $linkStatus);
            } else {
              $linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);
              $status = $this->cmsIconButton('Inactive', $this->imgUrl . '/icon/inactive.png', $linkStatus);
            }
          
            $order = $this->formText ( 'order[' . $id . ']', $value ['order'], array ('style' => 'width: 30px; text-align: center;' ) );
            // $members = $value ['members'];
            $linkInfo = $this->baseUrl($this->currentController . '/info/id/' . $id);
            $btnInfo = $this->cmsIconButton('Info', $this->imgUrl . '/icon_info.png', $linkInfo);
          
            $linkEdit = $this->baseUrl($this->currentController . '/edit/id/' . $id);
            $btnEdit = $this->cmsIconButton('Edit', $this->imgUrl . '/icon_edit.png', $linkEdit);
          
            $linkDelete = $this->baseUrl($this->currentController . '/delete/id/' . $id);
            $btnDelete = $this->cmsIconButton('Delete', $this->imgUrl . '/icon_del.png', $linkDelete);
          
            $strIconButton = $btnInfo . ' ' . $btnEdit . ' ' . $btnDelete;
          
            $cid = $this->formCheckbox('cid[]', $value['id']);
        ?>
        <tr class="even">
        	<td align="center"><?php echo $cid; ?></td>
        	<td align="left"><img src="<?php echo UPLOADS_URL .'/products/img80x75/'. $picture; ?>" alt="Product Image" /></td>
        	<td align="left"><?php echo $name; ?></td>
        	<td align="center"><?php echo $status; ?></td>
        	<td align="center"><?php echo $product_price; ?></td>
          <td align="center"><?php echo $order; ?></td>
        	<td align="center"><?php echo $category_name; ?></td>
        	<td align="center">
        	<?php echo $strIconButton; ?>
        	</td>
        	<td align="center"><?php echo $id; ?></td>
        </tr>
				<?php } ?>
				<!-- BEGIN: PAGINATION (FOOT) -->
				<tfoot>
					<tr>
						<td colspan="9">
							<div class="container">
								<div class="pagination">
									<?php
                    $currentUrl = $this->baseUrl($this->currentController . '/index');
                    echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('currentUrl' => $currentUrl));
                  ?>
									<div class="limit"></div>
								</div>
							</div>
						</td>
					</tr>
				</tfoot>
				<!-- END: PAGINATION (FOOT) -->
			</table>
			<!-- Area 4: In du lieu lay tu database - End -->
			<!-- END: ELEMENT BOX -->
			<div class="clr"></div>
		</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
	</div>
	<!-- END: 	CONTENT -->
</form>